<!DOCTYPE html>
<html lang="en">
<head>
    <title>意向客户列表</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <style>
        .lineOne {
            text-align: center;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: center;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak >
    <div class="div-td-content-more"><i></i></div>
    <div style="height: 25px;margin-bottom: 10px;">
        <input type="text" placeholder="关键字" class="form-control pull-left input-sm" style="width: 150px;"
               v-model="key">
        <button type="button" class="btn oaBtn btn-sm pull-left" style="margin-left: 10px;" @click="getList">查询</button>
    </div>
    <div class="box-body no-padding iframeH2" style="overflow: auto;" id="scrollDiv">
        <table class="table text-center table-width">
            <thead>
            <tr>
                <th style="width: 5%;" class="tableTitle">序号</th>
                <th style="width: 10%" class="tableTitle">客户姓名</th>
                <th style="width: 10%" class="tableTitle">电话</th>
                <th style="width:8%" class="tableTitle">意向机型</th>
                <th style="width: 8%" class="tableTitle">购买时间</th>
                <th style="width: 8%" class="tableTitle">付款方式</th>
                <th style="width: 51%" class="tableTitle">基本情况</th>
            </tr>
            </thead>
            <tbody>
            <tr v-for="(item,i) in intentionalCustomer.list">
                <td>{{i+1}}</td>
                <td @click="goIntent(item.customerId)" ><span style="text-align:center; color:#169BD5;cursor: pointer;"><div class="oa-name">{{item.customerName}}</div></span></td>
                <td>{{item.customerTel}}</td>
                <td class="lineOne"><span>{{item.intentionModel}}</span></td>
                <td>{{item.buyDate}}</td>
                <td>{{item.buyType}}</td>
                <td class="lineOne"><span>{{item.otherCondition}}</span></td>
            </tr>
            </tbody>
        </table>
        <div class="oa-pager text-center" style="margin-top: 5px;" v-if="isAll">
            共
            <span id="allCount"> 0 </span>条记录&nbsp;&nbsp;&nbsp;
            <span id="nowPage"> 1 </span>/<span id="allPage">1</span>&nbsp;&nbsp;&nbsp;
            <span class="oa-pager-button" id="first">首页</span>
            <span class="oa-pager-button" id="prev">上一页</span>
            <span class="oa-pager-button" id="next">下一页</span>
            <span class="oa-pager-button" id="last">尾页</span>
        </div>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    function refresh() {
        $.wyui.page.getByPage();
    }
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

    var app = new Vue({
        el: '#app',
        data: {
            userId: $.wyui.page.urlParams.userId ? $.wyui.page.urlParams.userId : getCurrentUser().id,
            regionId: $.wyui.page.urlParams.regionId ? $.wyui.page.urlParams.regionId : '',
            key:'',
            isAll: $.wyui.page.urlParams.isAll,
            intentionalCustomer: {
                time: new Date().Format("yyyy-MM-dd"),
                list: []
            }
        },
        methods: {
            changeBuyDate:function(buyDate){
                var a='';
                switch (buyDate) {
                    case 'todayMonth':
                        a='本月内'
                        break
                    case 'nextMonth':
                        a='下月内'
                        break
                    case 'threeMonth':
                        a='三月内'
                        break
                    case 'halfYear':
                        a='半年内'
                        break
                }
                return a;
            },
            getList: function () {
                var that = this;
                if (that.isAll=='true') {
                    /*$.wyui.postMethod(urlConfig.report.intentCustomer.getAllReportCustomer, {
                        "userId": that.userId,
                        "key": that.key
                    }, function (data) {
                        that.intentionalCustomer.list = data.records;
                    });*/
                    $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getAllReportCustomer
                    $.wyui.page.queryParams.requestPage=1;
                    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
                    $.wyui.page.getByPage()
                    //$.wyui.page.getByPage()
                } else {
                   /* $.wyui.postMethod(urlConfig.report.intentCustomer.getForPersonalIntentCustomerList, {
                        "userId": that.userId,
                        "key": that.key
                    }, function (data) {
                        that.intentionalCustomer.list = data.records;
                    });*/
                    $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
                    $.wyui.page.queryParams.requestPage=1;
                    $.extend($.wyui.page.queryParams, {userId: app.userId, key: app.key});
                    $.wyui.page.getByPage()
                }

            },
            goIntent: function (customerId) {
                var pt = 'look';
                var isRegion = '0'
                if (getCurrentUser().roleName == '区域经理') {
                    pt = 'edit';
                    isRegion = '1';
                }
                if (customerId && customerId != '') {
                    var H = $(window).height() - 50;
                    top.$.dialog({
                        content: 'url:/page/intentionManagement/quYuIntentionalDetailApp.html?customerId=' + customerId + '&isAdd=0&pageType=' + pt + '&userId=' + getCurrentUser().id + '&companyId=' + getCurrentUser().companyId + '&isRegion=' + isRegion + '&type=pcbb&index=0',
                        title: '意向客户详情',
                        width: 500,
                        height: H,
                        max: true,
                        min: true,
                        lock: true,
                    });
                }
            },
            /*打开客户详情页面*/
            openCustomerInfo:function (customerId) {
                var that = this;
                top.closeTabByPageId("openCustomerInfo");
                top.addTabs({
                    id: 'openCustomerInfo',
                    title: '意向客户详细信息',
                    close: true,
                    url: 'customer/customerDetails.html?customerId=' + customerId
                });
            }

        },
        mounted: function () {
            //if($.wyui.page.urlParams.isAll=="true"){
            //this.getList();
            // }
        }
    });
    if ($.wyui.page.urlParams.isAll == "true") {
        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getAllReportCustomer;
    }
    else {
        $.wyui.page.dataUrl = server.ip + urlConfig.report.intentCustomer.getForPersonalIntentCustomerList;
    }
    $.wyui.page.queryParams.pageType = $.wyui.page.urlParams.pageType;
    $.extend($.wyui.page.queryParams, {userId: app.userId, key: $.wyui.page.urlParams.key,regionId:app.regionId});
    $.wyui.page.getByPage_callback = function (records) {
        console.log(records)
        app.intentionalCustomer.list = records;
        document.getElementById("scrollDiv").scrollTop = 0;
    };
    $.wyui.page.getByPage_scroll_callback = function (list) {
        if (list.length < 30) {
            isLoad = false;
        } else {
            for (var i = 0; i < list.length; i++) {
                app.intentionalCustomer.list.push(list[i]);
            }
            isLoad = true;
        }
        ;
    }
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');
    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        // console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }

    divscroll.onscroll = divScroll;
</script>
</body>
</html>